<template>
  <div class="home">
    <van-nav-bar title="首页" />
    <van-search v-model="value" placeholder="请输入搜索关键词" />
    <van-tabs v-model="active" @click="tabClick">
      <van-tab :title="item" v-for="(item, index) in title" :key="index">
        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="onLoad"
        >
          <OrderBox :listData="listData"></OrderBox>
        </van-list>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { get } from "@/utils/request.js";
import OrderBox from "@/components/OrderBox.vue";
export default {
  data() {
    return {
      active: 0,
      value: "",
      params: {
        page: 1,
        pageSize: 100,
        status: "待接单",
      },
      title: ["全部", "安装", "维修", "拆机"],
      listData: [],
      loading: false,
      finished: false,
    };
  },
  components: {
    OrderBox,
  },
  created() {
    this.getAllWorkOrdersByType();
  },
  methods: {
    getAllWorkOrdersByType() {
      get("/workorder/pageQuery", this.params).then((res) => {
        this.listData = res.data.list;
      });
    },
    onLoad() {},
    tabClick(name, title) {
      this.params.type = "";
      if (title == "全部") {
        this.getAllWorkOrdersByType();
      } else {
        this.params.type = title;
        this.getAllWorkOrdersByType();
      }
    },
  },
};
</script>

<style lang="less" >
</style>